package com.cloud.hello.impl.controller;

import com.cloud.hello.impl.client.UserClient;
import com.cloud.hello.impl.service.HelloService;
import com.lwj.framework.degest.DigestSignature;
import com.lwj.framework.security.AuthEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.lwj.logger.api.LogMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;


/**
 * @Author: :lwj
 * @Time: 2018-10-21 18:40
 * @Feature:
 */

@Api(tags ="测试")
@Controller
public class HelloController {
    @Autowired
    private HelloService helloService;


    /**
     * @return
     */
    @ApiOperation(value = "hello1")
    @GetMapping("/hello1")
    @LogMethod
    @RolesAllowed("xxx")
    public ResponseEntity<String> hello1(Long id, HttpServletRequest request){
        String key = request.getParameter("token");
        return ResponseEntity.ok(key+"777");
    }


    /**
     * @return
     */
    @ApiOperation(value = "hello2")
    @PostMapping("/hello2")
    @LogMethod
    public ResponseEntity<String> hello2(@RequestParam("file") MultipartFile file){
        String result="param=====";
        return ResponseEntity.ok(result);
    }
    /**
     * @return
     */
    @ApiOperation(value = "hello3")
    @PostMapping("/hello3")
    public ResponseEntity<String> hello3(){
        String s = helloService.testHystrixCommand();
        return ResponseEntity.ok(s);
    }


    /**
     * @return
     */
    @ApiOperation(value = "feignThreadTest")
    @GetMapping("/feignThreadTest")
    @LogMethod
    public ResponseEntity<String> feignThreadTest(){
        return ResponseEntity.ok("hello");
    }
    /**
     * @return
     */
    @ApiOperation(value = "testToken")
    @GetMapping("/testToken")
    @LogMethod
    public ResponseEntity<String> feignThreadTest2(){
        return ResponseEntity.ok("hello2");
    }
}
